<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <script src="./01-栈的实现.js"></script> -->
    <script>
        
/**
 * @param {number[]} temperatures
 * @return {number[]}
 */
var dailyTemperatures = function(temperatures) {
    const end = []
    const stack = [0]
    for(let i = 1; i< temperatures.length; i++) {
        while(temperatures[stack[stack.length-1]] < temperatures[i]){
            console.log(i , stack[stack.length-1])
            end[stack[stack.length-1]] = (i - stack[stack.length-1])
            stack.pop()
        }
        stack.push(i)
    }
    if(stack.length){
        stack.forEach(()=>{
            end.push(0)
        })
    }
    return end
};
console.log(dailyTemperatures([73,74,75,71,69,72,76,73]))
    </script>
</body>
</html>